package src.main.java.org.stringBuilder;

public class Test2 {
    public static void main(String[] args) {
        System.out.println(getArrayData(new int[]{11, 22, 33}));
    }
    public static String getArrayData(int[] arr){
        //1.判断arr是否为null
        if(arr == null){
            return null;
        }
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append("[");
        for (int i = 0; i < arr.length; i++) {
            if(i== arr.length-1){
                stringBuilder.append(arr[i]);
            }else{
                stringBuilder.append(arr[i]).append(", ");
            }

        }
        stringBuilder.append("]");
        return stringBuilder.toString();
    }
}
